/**
 * 
 */
package tokens;

import java.util.ListIterator;
import java.util.Queue;
import java.util.Stack;

import parser.ParserException;
import nodes.AbstractNode;
import nodes.binary.ModNode;

/**
 * @author Charlie Hatcher
 * @author Andrew
 *
 */
public class ModToken extends AbstractBinaryToken
{
	private static final String MOD_TOKEN = "\\%";
	
	public ModToken(){
		precedence = 1;
	}

	@Override
	public AbstractNode process() {
		return new ModNode(myModel);
	}


	@Override
	public boolean matchToken(String str, ListIterator<String> it) {
		return str.matches(MOD_TOKEN);
	}

	 public String toString ()
	    {
	        return syntaxBundle.getString("mod_label");
	    }

	@Override
	public void handleParser(String str, ListIterator<String> it,
			Stack<AbstractBinaryToken> opStack,
			Queue<AbstractNode> outPutQueue, Queue<AbstractNode> queue)
			throws Exception {
		if(!outPutQueue.isEmpty()){
			AbstractNode temp = outPutQueue.poll();
			outPutQueue.add(new ModToken().process());
			outPutQueue.add(temp);
		}
		else throw ParserException.BAD_SYNTAX; 
		
	}
}